<script setup>
import { reactive, ref } from "vue";
import message from "@arco-design/web-vue/es/message";
import { addResignationRequestsUsingPost } from "@/api/resignationRequestsController";
import { useRouter } from "vue-router";
const router = useRouter();
const isNumber = ref(1);
let idid = {
  id: "",
};
const form = reactive({
  phone: 0,
  reason: "",
  resTime: "",
  userName: "",
});
const addResignationRequestsUsingPostData = async () => {
  const res = await addResignationRequestsUsingPost(form);
  if (res.data.code == 0) {
    idid.id = res.data.data;
    message.success("提交成功,等待审批");
    isNumber.value = 2;
  } else {
    message.error(res.data.message);
  }
};
const handleSubmit = () => {
  addResignationRequestsUsingPostData();
};

const aaa = () => {
  router.push("/myresignation");
};

const delData = () => {
  for (let key in form.value) {
    form.value[key] = ""; // 或者根据实际情况设置为其他默认值，如 ''、0、false 等
  }
};
</script>

<template>
  <a-layout style="height: 400px">
    <a-layout-header>
      <a-steps type="dot" :current="isNumber">
        <a-step>填写申请</a-step>
        <a-step>提交申请</a-step>
      </a-steps>
    </a-layout-header>
    <a-layout-content>
      <a-form
        :model="form"
        :style="{ width: '600px' }"
        @submit="handleSubmit"
        style="margin-left: 30%; margin-top: 100px"
        label-align="left"
      >
        <a-form-item
          field="name"
          tooltip="Please enter username"
          label="辞工人姓名"
        >
          <a-input v-model="form.userName" placeholder="请输入姓名" />
        </a-form-item>
        <a-form-item field="post" label="辞职原因">
          <a-textarea
            placeholder="请输入事由"
            allow-clear
            v-model="form.reason"
          />
        </a-form-item>
        <a-form-item field="isRead" label="预计离职时间">
          <a-date-picker style="width: 200px" v-model="form.resTime" />
        </a-form-item>
        <a-form-item
          field="name"
          tooltip="Please enter username"
          label="手机号码"
        >
          <a-input v-model="form.phone" placeholder="手机号码" />
        </a-form-item>
        <a-form-item>
          <a-button html-type="submit">提交</a-button>
          <a-button
            type="outline"
            status="danger"
            @click="delData"
            style="margin-left: 20px"
            >清空</a-button
          >
          <a-button @click="aaa" style="margin-left: 50px"
            >查看审批结果</a-button
          >
        </a-form-item>
      </a-form>
    </a-layout-content>
  </a-layout>
</template>

<style scoped></style>
